<?php
namespace Admin\Controller;
use Think\Controller;

class ManageController extends Controller {

    Public function index($str){
        $this->str = M("$str")->select();
        $this->display('index_'."$str");
    }

    Public function add($str,$idName){

        $siz = M("$str")->order('id desc')->limit(1)->field("$idName")->select();
        $this->assign('Nowsid',$siz['0']["$idName"]+1);

        if ($_POST['submit']=='提交'){
            $Validation = new \Admin\Model\ValidationModel();
            if ($res = $Validation->validation($_POST["$str"],'null')){
                $this->error($res);
            }
            $data = array(
                /*
                    此处有个大bug 使sid与id不一致
                 */
                "$str" => $_POST["$str"],
                "$idName" => $siz['0']["$idName"]+1,
            );
            if ($pd = M("$str")->data($data)->add()){
                $this->success('添加成功!',U("Manage/index?str=$str"));
            }
        }else{
            $this->display('add_'."$str");
        }
    }

    Public function update($str,$id){
        if (){

        }else{

        }
        $this->display('update_'."$str");
    }
}

?>